package com.googlecode.continuity.core.server.hibernate;

import net.sf.hibernate4gwt.core.beanlib.clone.CloneBeanReplicator;
import net.sf.hibernate4gwt.core.beanlib.IClassMapper;
import net.sf.hibernate4gwt.core.beanlib.TimestampCustomTransformer;
import net.sf.beanlib.spi.CustomBeanTransformerSpi;
import net.sf.beanlib.spi.BeanTransformerSpi;

/**
 * CloneBeanReplicatorEnum implements a custom {@link CloneBeanReplicator} that allows for Enum's and timestamps to be
 * transformed. 
 *
 * @author Peter Schmitt <aragos@aragos.de>
 */
public class CloneBeanReplicatorEnum extends CloneBeanReplicator {
  /**
   * Constructs a new CloneBeanReplicatorEnum which registers a custom transformer for timestamps and enums.
   * @param iClassMapper
   */
  public CloneBeanReplicatorEnum(IClassMapper iClassMapper) {
    super(iClassMapper);
    initCustomTransformer(new CustomBeanTransformerSpi.Factory() {
      public CustomBeanTransformerSpi newCustomBeanTransformer(final BeanTransformerSpi beanTransformer) {
        return new CustomTransformerTimestampEnum(beanTransformer);
      }
    });
  }

}
